/**
 * 2017年12月22日
 */
package exp.algorithm.sic.feature;

import java.util.ArrayList;
import java.util.List;

import exp.algorithm.sic.ScalePeak;
import exp.algorithm.sic.TimeSeries;

/**
 * 将原来的保持原来的数据不变
 * @author Alex
 *
 */
public class OriginalFeatureVectorMaker implements FeatureVectorMaker {
	int defaultLength = 20;
	@Override
	public List<FeatureVector> createFeatureDescriptor(List<ScalePeak> peaks, TimeSeries[] tss) {
		List<FeatureVector> result = new ArrayList<FeatureVector>();
		for(ScalePeak sp:peaks){
			int level = sp.level;
			TimeSeries ts = tss[level];
			int beginx = (sp.x - defaultLength/2);
			int endx = sp.x+defaultLength/2;
			float arr[] = new float[defaultLength];
			int idx = 0;
			for(int i=beginx;i<endx;i++){
				if(i<0){
					idx++;
				}else if(i<ts.length()){
					arr[idx++] = ts.data[i];
				}else{
					break;
				}
			}
			result.add(new DenseFeatureVector(arr));
			
		}
		return result;
	}

}
